package com.example.demo.ai.upload;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UploadImageDriController {

    @Autowired
    private UploadImageDriService uploadImageDriService;

    @PostMapping("/api/upload")
    public ResponseEntity<String> uploadFolderToSsh(@RequestParam("folderPath") String localFolderPath) {
        try {
            String path = uploadImageDriService.uploadFolder(localFolderPath);
            return ResponseEntity.ok("文件夹上传成功: " + path);
        } catch (Exception e) {
            return ResponseEntity.badRequest().body("上传失败: " + e.getMessage());
        }
    }
}
